/**
 * 
 */
package idv.takeshi.software.productline.bookstore.domain.model.useraccount;

import java.util.Collection;
import java.util.List;
import java.util.Set;

import org.apache.commons.lang.Validate;

/**
 * A model repository for user account aggregate models.
 * @author takeshi
 *
 */
public interface UserAccountRepository {
	
	
	/**
	 * Add a UserAccount.
	 * @param userAccount
	 * @throws UserAccountDuplicateException 
	 */
	public void add(UserAccount userAccount) throws UserAccountDuplicateException;
	
	/**
	 * Find a UserAccount by it's id.
	 * @param id
	 * @return
	 */
	public UserAccount findById(Long id);
	
	/**
	 * Find by account name.
	 * @param accountName
	 * @return
	 */
	public UserAccount findByAccountName(String accountName);
	
	/**
	 * Find a userAccount by it's activation key.
	 * @param activationKey
	 * @return
	 */
	public UserAccount findByActivationKey(String activationKey);
	
	
	
	/**
	 * Find by role, account name and account type.
	 * @param role
	 * @param accountName
	 * @param accountType - individual or organization account type.
	 * @return
	 */
	public Set<UserAccount> findByRoleAccountNameAndAccountType(String role, String accountName, String accountType);
	
	/**
	 * Remove a UserAccount.
	 * @param userAccount
	 */
	public void remove(UserAccount userAccount);
	
	/**
	 * Remove roles.
	 * @param roles
	 */
	public void remove(Collection<Role> roles);
	
	/**
	 * Find a list of email addresses by given role.
	 * @param <T>
	 * @param roleClass
	 * @return
	 */
	public <T extends Role> List<String> findEmailAddressesByRole(Class<T> roleClass);

	/**
	 * Get userAccount by orderId.
	 * @param orderId
	 * @return
	 */
	public UserAccount findByOrderId(Long orderId);
	
	/**
	 * Find all user accounts.
	 * @return
	 */
	public Set<UserAccount> findAll();
	
	/**
	 * Find user accounts by given ID(s)
	 * @param ids
	 * @return
	 */
	public Set<UserAccount> findByIds(Long[] ids);

}
